package cn.yeziji.forum.bo.file;

import cn.yeziji.forum.entity.ForumFileEntity;
import cn.yeziji.forum.basic.file.WebUploaderFileEntity;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.Date;

/**
 * file 数据传输
 *
 * @author gzkemays
 * @since 2022/5/18 8:40
 */
@Data
@AllArgsConstructor
public class FileBO {
  String scope;
  String target;
  String source;
  String desc;
  String image;
  Long size;

  public FileBO(String scope, String source) {
    this.scope = scope;
    this.source = source;
  }

  public FileBO(WebUploaderFileEntity wfe) {
    this.scope = wfe.getScope();
    this.source = wfe.getSource();
    this.target = wfe.getTarget();
    this.desc = wfe.getDesc();
    this.size = wfe.getSize();
    this.image = wfe.getImage();
  }

  public ForumFileEntity buildEntity() {
    ForumFileEntity entity = new ForumFileEntity();
    entity.setScope(scope);
    entity.setTarget(target);
    entity.setSource(source);
    entity.setSize(size);
    entity.setImage(image);
    entity.setCreateTime(new Date());
    return entity;
  }
}
